import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'ant-design-vue/dist/antd.css'
import Antd from 'ant-design-vue'
import APlayer from '@moefe/vue-aplayer'
import VueLazyload from 'vue-lazyload'
import '@/permission'
import hljs from 'highlight.js'
import 'highlight.js/styles/googlecode.css' // 样式文件
import './global.css'
// 自定义指令
Vue.directive('highlight', function(el) {
  const blocks = el.querySelectorAll('pre code')
  blocks.forEach((block) => {
    hljs.highlightBlock(block)
  })
})
Vue.config.productionTip = false
Vue.use(Antd)
router.beforeEach((to, from, next) => {
  // chrome
  document.body.scrollTop = 0
  // firefox
  document.documentElement.scrollTop = 0
  // safari
  window.pageYOffset = 0
  next()
})
Vue.use(APlayer, {
  defaultCover: 'https://github.com/u3u.png',
  productionTip: true
})
Vue.use(VueLazyload, {
  preLoad: 0.9,
  error: process.env.VUE_APP_LOADING__ERROR_IMG,
  loading: process.env.VUE_APP_LOADING_IMG,
  attempt: 1
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')

